home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mintmant / pmsg.txt < prev    next >
Text File  |  1992-03-24  |  3KB  |  130 lines

  1. Pmsg(2)                   Oct. 1, 1991                    Pmsg(2)
  2.  
  3.  
  4.  
  5. NAME
  6.      Pmsg - send and receive brief messages
  7.  
  8. SYNOPSIS
  9.      struct msg { LONG msg1, msg2; WORD pid; };
  10.  
  11.      LONG Pmsg( WORD mode, LONG mboxid, struct msg *msgptr );
  12.  
  13. DESCRIPTION
  14.      Pmsg sends or receives a message to a specified message box.
  15.      What  sort  of operation is performed depends on the bits in
  16.      mode as follows:
  17.         Mode        Operation
  18.         0x0000      read
  19.         0x0001      write
  20.         0x0002      write, then read from mboxid 0xFFFFxxxx where
  21.                  xxxx is the process id of the current process
  22.  
  23.         0x8000      OR with this bit to make the operation
  24.                  non-blocking.
  25.  
  26.      The messages are five words long: two longs and a short,  in
  27.      that  order.  The values  of the first two longs are totally
  28.      up to the processes in question.  The value of the short  is
  29.      the  PID of the sender.  On return from writes, the short is
  30.      the PID of the process that read your  message.   On  return
  31.      from reads, it's the PID of the writer.
  32.  
  33.      If the 0x8000 bit is set in the mode, and  there  is  not  a
  34.      reader/writer  for the mboxid already, this call returns -1.
  35.      Otherwise, a read operation waits until a message is written
  36.      and a write operation waits for a reader to receive the mes-
  37.      sage.
  38.  
  39.      In mode 2, the writer is declaring that it wants to wait for
  40.      a  reply  to  the  message.  What happens is that the reader
  41.      gets put on the ready queue, but the  writer  is  atomically
  42.      turned   into   a  reader  on  a  mailbox  whose  mboxid  is
  43.      (0xFFFF0000 | pid). The idea is that this process will sleep
  44.      until  awoken  at  a later time by the process that read the
  45.      message.   The  process  reading  the  original  request  is
  46.      guaranteed not to block when writing the reply.
  47.  
  48.  
  49. RETURNS
  50.      0 if successful
  51.  
  52.      -1 if bit 0x8000 is set and the  Pmsg  call  would  have  to
  53.      block
  54.  
  55.      EINVFN if mode is invalid
  56.  
  57.  
  58.  
  59.  
  60. Version 0.9   Last change: MiNT Programmer's Manual             1
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. Pmsg(2)                   Oct. 1, 1991                    Pmsg(2)
  68.  
  69.  
  70.  
  71. USAGE
  72.      Used for short messages and as a way to  do  rendezvous  and
  73.      interprocess  communication  with  little overhead. For more
  74.      complicated messages or  more  general  IPC,  use  FIFOs  or
  75.      pseudo-terminals.
  76.  
  77. BUGS
  78.      There is no provision for a timeout.
  79.  
  80.      No checking is done for deadlocks. A deadlock could arise in
  81.      the  following way: Say PID 33 writes in mode 2 to a message
  82.      box and it blocks. Then somebody writes to PD33 ( i.e.  mes-
  83.      sage  box  (0xFFFF0000 | 33) ) and blocks because you're not
  84.      waiting for it.  Then your write is satisfied, so you become
  85.      a  reader  on PD33.  We should check to see if there are any
  86.      writers on PD33 and satisfy that rendezvous! But this  could
  87.      go  on  forever, and it's easier to stop here.  So you lose:
  88.      this situation is timing sensitive.  It  shouldn't  come  up
  89.      anyway.
  90.  
  91. AUTHOR
  92.      Allan K. Pratt
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. Version 0.9   Last change: MiNT Programmer's Manual             2
  127.  
  128.  
  129.  
  130.